package com.seata.example.inventory.dubbo;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.seata.example.api.InventoryDubboService;
import com.seata.example.inventory.entity.Inventory;
import com.seata.example.inventory.service.InventoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 */
@DubboService
public class InventoryDubboServiceImpl implements InventoryDubboService {
    @Autowired
    private InventoryService inventoryService;

//    @Transactional
    @Override
    public void reduceInventory(Long id, Long number) {
        Inventory inventory = inventoryService.getById(id);
        inventory.setNumber(inventory.getNumber() - number);
        inventoryService.updateById(inventory);
    }
}
